---
title: 'XPolaris: Retrieving Soil Data from POLARIS'
author: 'L. Moro Rosso, A. de Borja Reis, A. Correndo & I. Ciampitti'
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
```

# Introduction

```{r}
# Installation may ask for updating some packages
# install.packages('XPolaris')
library(XPolaris)
```

# Example locations

```{r}
df.loc <- exkansas # Replace with your own coordinates data.frame
```

# Checking images

```{r fig.height=5, fig.width=7}
xplot(locations = df.loc,
      localPath = getwd()) # Users can set any path
```

# Downloading images

```{r}
df.out <- ximages(locations = df.loc,
                  
                  variables = c(
                    
                    'ph',
                    'om',
                    'clay',
                    'silt',
                    'sand' #,
                    #'bd',
                    #'hb',
                    #'n',
                    #'alpha',
                    #'ksat',
                    #'lambda',
                    #'theta_r',
                    #'theta_s'
                    
                    ),
                  
                  statistics = c(
                    
                    'mean' #,
                    #'mode',
                    #'p50',
                    #'p5',
                    #'p95'
                    
                    ),
                  
                  layersdepths = c(
                    
                    '0_5',
                    '5_15',
                    '15_30' #,
                    #'30_60',
                    #'60_100',
                    #'100_200'
                    
                    ),
                  
                  localPath = getwd())
```

# Extracting soil data

```{r}
xsoil(ximages_output = df.out, # Object created by ximages
      localPath = getwd())
```
